<template>
	<div class="page-container">
		<page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />

		<ex_super_table_page
			v-bind="option"
			ref="SuperTablePage"
			@selection-change="e => (selection = e)"
		>
		</ex_super_table_page>
		<ex_super_dialog_form ref="formDialog" v-bind="dialog"> </ex_super_dialog_form>
	</div>
</template>
<script>
import role_system_mixin from '@/mixin/role_system_mixin'

import superTablePageFunction from '@/mixin/super-table-page-function'
import page_table_model_manage from '@/mixin/page_table_model_manage'
export default {
	title: 'label_request_message_log',
	mixins: [superTablePageFunction, page_table_model_manage, role_system_mixin],
	components: {},
	data() {
		return {
			detailType: null,
			option: {
				search: {
					default: { requestType: 'GROUP' },
					model: [
						{
							key: 'requestType',
							label: 'label_type',
							type: 'radio-group',
							enum: 'RequestTypeEnum',
							attrs: { border: true, button: true },
							on: {
								input: () => {
									this.$refs.SuperTablePage.loadDataForSearch()
								}
							}
						}
					]
				},

				table: {
					url: '',
					urlDataHandle: (res) => {
						const requestType = this.$refs.SuperTablePage.getSearchData().requestType
						let list =  []
						if(res&&res.data&&res.data.rows)list = res.data.rows
						list.forEach(it => (it.type = requestType))
						return list
					},
					model: this.init_table_model()
				}
			},
			dialog: {
				customClass: 'dialog_extra',
				detailUrl: '',
				form: {
					model: [
						{
							key: 'groupValue',
							label: '分组值',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, code)
							}
						},
						{
							key: 'requestNo',
							label: '请求号',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, code)
							}
						},

						{
							key: 'className',
							label: 'className',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, code)
							}
						},
						{
							key: 'methodName',
							label: 'methodName',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, code)
							}
						},
						{
							key: 'paramTypeNames',
							label: 'paramTypeNames',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, JSON.stringify(code))
							}
						},
						{
							key: 'paramInputs',
							label: 'paramInputs',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, JSON.stringify(code))
							}
						},
						{
							key: 'context',
							label: 'context',
							render: (h, { data, item }) => {
								const code = data[item.key]
								return this.$renderText(h, JSON.stringify(code))
							}
						}
					]
				}
			}
		}
	},
	created() {
		if (this.isWmsSystem) {
			this.option.table.url = '/wms-api/request/WmsRequestRpc/selectAll.json'
		} else {
			this.option.table.url = '/oms-api/request/OmsRequestRpc/selectAll.json'
		}
    if (this.isWmsSystem) {
			this.dialog.detailUrl = '/wms-api/request/WmsRequestRpc/detail.json'
		} else {
			this.dialog.detailUrl = '/oms-api/request/OmsRequestRpc/detail.json'
		}
	},
	methods: {
		option_table_model() {
			return [
				{
					key: 'groupValue',
					label: '分组值',
					// renderHeader: (h, { column }) => {
					// 	return (
					// 		<div>
					// 			{this.$t(column.label)}
					// 			<el-tooltip
					// 				effect="light"
					// 				content="用于异步调用时消息队列中的排序"
					// 				placement="top"
					// 			>
					// 				<i class="el-icon-question"></i>
					// 			</el-tooltip>
					// 		</div>
					// 	)
					// },
					'min-width': 140,
					render: (h, { row, column }) => {
						const code = row[column.property]
						if (!code) return this.$renderText(h, code)
						return (
							<text_extra_tooltip_operate
								value={code}
								ellipsis
								data_type={column.property}
								data_id={row.id}
							/>
						)
					}
				},

				{
					key: 'requestNo',
					label: '请求号',
					'min-width': 140,
					render: (h, { row, column }) => {
						const code = row[column.property]
						if (!code) return this.$renderText(h, code)
						return (
							<text_extra_tooltip_operate
								value={code}
								ellipsis
								data_type={column.property}
								data_id={row.id}
							/>
						)
					}
				},

				{
					key: 'className',
					label: 'className',
					width: 140,
					render: (h, { row, column }) => {
						const code = row[column.property]
						if (!code) return this.$renderText(h, code)
						return (
							<text_extra_tooltip_operate
								value={code}
								ellipsis
								data_type={column.property}
								data_id={row.id}
							/>
						)
					}
				},
				{
					key: 'methodName',
					label: 'methodName',
					width: 120,
					render: (h, { row, column }) => {
						const code = row[column.property]
						if (!code) return this.$renderText(h, code)
						return (
							<text_extra_tooltip_operate
								value={code}
								ellipsis
								data_type={column.property}
								data_id={row.id}
							/>
						)
					}
				},
				{
					key: 'paramTypeNames',
					label: 'paramTypeNames',
					width: 140,
					render: (h, { row, column }) => {
						const code = row[column.property]
						if (!code) return this.$renderText(h, code)
						return (
							<text_extra_tooltip_operate
								value={code}
								ellipsis
								data_type={column.property}
								data_id={row.id}
							/>
						)
					}
				},
				{
					key: 'apiCode',
					label: 'apiCode',
					width: 140
				},
				{
					key: 'retryCount',
					label: 'label_retry_count',
					width: 120
				},
				{
					key: 'gmtCreate',
					label: 'label_create_time',
					width: 150,
					formatter: (r, c, v, i) => this.$dateFormatTime(v)
				},
				{
					type: 'operate',
					width: 160,
					operate: [
						{
							label: 'label_view_detail',
							click: row => {
								this['$refs']['formDialog'].showNew({
									title: this.$tt('label_view_detail'),
									params: { requestType: row['type'], id: row['id'] }
								})
							}
						}
					]
				}
			]
		}
	}
}
</script>
<style></style>
